import $ from 'jquery';
import _common from '../commonJs/wptx_common';
import _tools from '../commonJs/wptx_tools';
import _request from '../../utils/request';
let _FUNCTION_NAME = "/portalapi/syncdata/";
export default {
    page: _page, //  [API]查询主任务列表
    pageMongoContent: _pageMongo, //根据contentId 查询Mongo数据

}
function _page(vm, pageData, callBack, searchParams) {
    let self = vm;
    _tools.info("===> 【" + pageData + "】 -- > pageData")
    _tools.info("===> 【" + searchParams + "】 -- > searchParams")
    let url = _FUNCTION_NAME + "task/subtask_page";
    let params = {
        pageNo: pageData.pageNo ? pageData.pageNo : 1,
        pageSize: pageData.pageSize ? pageData.pageSize : 10
    }
    $.each(searchParams, function (name, val) {
        if (val != undefined && val != null && $.trim(val) != "") {
        params[name] = val;
        }
    });
    _request({
        url: url,
        method: 'post',
        data: params
    }).then((res) => {
        _tools.info("===> 【" + url + "】 -- > API 调用成功 ")
        _tools.info(res)
        callBack(res.result);
    }).catch((error) => {
        _tools.info("===> 【" + url + "】 -- > API 调用异常 ")
        _tools.error(error);
        // callBack(null);
    });
}
function _pageMongo(vm, pageData, callBack, searchParams) {
    let self = vm;
    _tools.info("===> 【" + pageData + "】 -- > pageData")
    _tools.info("===> 【" + searchParams + "】 -- > searchParams")
    let url = _FUNCTION_NAME + "task/subtask_content";
    let params = {
        pageNo: pageData.pageNo ? pageData.pageNo : 1,
        pageSize: pageData.pageSize ? pageData.pageSize : 10
    }
    $.each(searchParams, function (name, val) {
        if (val != undefined && val != null && $.trim(val) != "") {
            params[name] = val;
        }
    });
    _request({
        url: url,
        method: 'post',
        data: params
    }).then((res) => {
        _tools.info("===> 【" + url + "】 -- > API 调用成功 ")
        _tools.info(res)
        // callBack(res.result);
        callBack(res.result);
    }).catch((error) => {
        _tools.info("===> 【" + url + "】 -- > API 调用异常 ")
        _tools.error(error);
        // callBack(null);
    });
}
